<?php
namespace app\topics\service;

/**
 * 标签接口
 */
class LabelService {

    /**
     * 栏目列表
     */
    public function nodeList($data) {
        $where = [];
        return target('topics/TopicsNode')->nodeList();
    }

    /**
     * 栏目列表
     */
    public function detailList($data) {
        $where = [];
        if($data['top']) {
            $where['A.attr_top'] = 1;
        }
        if($data['excellent']) {
            $where['A.attr_excellent'] = 1;
        }
        //其他条件
        if (!empty($data['where'])) {
            $where['_sql'][] = $data['where'];
        }
        //调用数量
        if (empty($data['limit'])) {
            $data['limit'] = 10;
        }
        //内容排序
        if (empty($data['order'])) {
            $data['order'] = 'A.update_time desc';
        }
        return target('topics/TopicsDetail')->loadList($where,$data['limit'], $data['order']);
    }

    /**
     * 栏目列表
     */
    public function tagList($data) {
        $where = [];
        //其他条件
        if (!empty($data['where'])) {
            $where['_sql'][] = $data['where'];
        }
        //调用数量
        if (empty($data['limit'])) {
            $data['limit'] = 10;
        }
        //内容排序
        if (empty($data['order'])) {
            $data['order'] = 'quote desc, tags_id desc';
        }
        return target('topics/TopicsTags')->loadList($where,$data['limit'], $data['order']);
    }

}
